package m202311.d07;

/**
 * @author haocongshun
 * @date 2023/11/07 18:55:42
 */

import java.util.Arrays;

/**
 * 274. H 指数
 */
public class Q274 {

    public static void main(String[] args) {
        int i = new Q274().hIndex(new int[]{4,0,6,1,5});
        System.out.println(i);
    }

    public int hIndex(int[] citations) {
        Arrays.sort(citations);
        for (int i = 0; i < citations.length; i++) {
            if (citations[i] >= citations.length - i) {
                return citations.length - i;
            }
        }
        return 0;
    }
}
